home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 886 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  972 b 

  1. Path: earth.njcc.com!is2
  2. From: chris@pluto.njcc.com (Chris Conway)
  3. Newsgroups: comp.lang.c++
  4. Subject: Help with cin.get()
  5. Date: 8 Jan 1996 05:54:50 GMT
  6. Organization: New Jersey Computer Connection
  7. Message-ID: <4cqbja$62n@earth.njcc.com>
  8. NNTP-Posting-Host: ts2-68.njcc.com
  9. X-Newsreader: News Xpress Version 1.0 Beta #4
  10.  
  11. I use this function to input a book title with imbedded blanks:
  12.  
  13.     void getdata()
  14.        {
  15.        cout << "Enter title: ";
  16.        cin.get(title, LEN);
  17.        cout << "Enter price: ";
  18.        cin >> price;
  19.        }
  20.  
  21. problem is, if I execute the function more than once, it skips the title input 
  22. on the second and every subsequent execution (i.e. the line will resemble:
  23.      Enter title: Enter price: 
  24. never offering the oppurtunity to enter the title).
  25.  
  26. I suspect this little "bug" arises from a subtle misuse of cin.get().  Can 
  27. anyone identify it for me?  This is obviously a beginner question.
  28.  
  29. My thanks and apologies.
  30. chris.
  31. chris@pluto.njcc.com
  32.